//从插件内导出createRouter,createWebHashHisory
import { createRouter , createWebHashHistory } from "vue-router";

//导入组件
import LoginCom from "@/components/LoginCom.vue";
import HomeCom from "@/components/HomeCom.vue";
import RegisterCom from "@/components/RegisterCom.vue";
//首页子路由
  //子路由
  import AddPerson from "@/components/home/AddPerson.vue";
  import ListPerson from "@/components/home/ListPerson.vue";
  import SchoolList from "@/components/home/SchoolList.vue";
  import EditPerson from "@/components/home/EditPerson.vue";
  import Koinlist from "@/components/home/Koinlist.vue";


//定义路由表
const routes = [
    {
        path : '/',
        redirect : {
            name : 'LoginCom'
        }
        // redirect : '/login'
    },
  {
    path : '/login',
    name : "LoginCom",
    component : LoginCom,
  },
  {
    path : '/register',
    name : "RegisterCom",
    component : RegisterCom,
  },
  {
    path : '/home',
    name : "HomeCom",
    component : HomeCom,    

    //children属性：设置首页的子路由
    children:[
      {
        path : 'addperson',

        name : "AddPerson",
        component : AddPerson
      },
      {

        path : 'listperson',

        name : "ListPerson",
        component : ListPerson
      },
      {

        path : 'schoollist',

        name : "SchoolList",
        component : SchoolList
      },
      {
        path : 'editperson',
        name : 'EditPerson',
        component :EditPerson
      },
      {
        path : 'koinlist',
        name : 'Koinlist',
        component :Koinlist
      }
    ]

  }

  


];

//定义路由器/创建路由器
const router = createRouter({
  
    routes,
    history : createWebHashHistory(),
});

//导出路由器
export default router;